package com.rover022.tool.view
{
	import com.bit101.components.Window;
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;

	public class ComposePane extends Sprite
	{
		public var windows:Window;
		public var maxItem:int = 6;

		public function ComposePane()
		{
			windows = new Window(this);
			windows.hasMinimizeButton = true;
			windows.hasCloseButton = true;
			windows.width = 1000;
			windows.height = 200;
			windows.addEventListener(Event.CLOSE, closeClick);
		}

		protected function closeClick(event:Event):void
		{
			parent.removeChild(this);
		}

		public function addBox(src:DisplayObject):void
		{
			windows.content.addChild(src);
			sort();
		}

		public function checkCompose():Boolean
		{
			for (var i:int = 0; i < windows.content.numChildren; i++)
			{
			}
			return false;
		}

		public function sort():void
		{
			for (var i:int = 0; i < windows.content.numChildren; i++)
			{
				var item:DisplayObject = windows.content.getChildAt(i);
				item.x = 100 * (i % 8);
				item.y = 100 * int(i / 8);
			}
		}

		public function removeBox(child:DisplayObject):void
		{
			windows.content.removeChild(child);
			sort();
		}

		public function canAugment():Boolean
		{
			if (windows.content.numChildren >= maxItem)
			{
				return false;
			}
			else
			{
				return true;
			}
		}
	}
}
